package bairui.international.console.web.controller.barter.product;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.project.commons.util.Util_FileDeal;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_Product;
import bairui.international.service.Service_Product;

/**
 *
 * 物料编辑
 *
 * @generated
 * 
 * @see STest_C_Barter_Product_Edit_Edit 测试
 *
 */
@Controller
public class C_Barter_Product_Edit_Edit
 extends SC_Barter_Product_Edit_Edit 
{
	
	@Autowired private Service_Product service_Product;
	
	/**
	 * 编辑
	 */
	@Action(Edit.class)
	@PostMapping(Edit.RequestMappingValue)
	public @FomatOutput @ResponseBody Object edit(
		@Valid Edit.InputModel input, 
		@PathVariable(name=Edit.PathVariableName.Id) long id
	) throws Exception {
		// 更新数据
		TB_Product bean = service_Product.updateWithRootCategory(id, input);
		// 更新图片
		Util_FileDeal.updateFile(input.getImgUrlFile(), bean.getImgUrl(), pathConfig.getPosition_Image_Product());
		//
		return null;
	}
	

}
